<template>
  <!-- 分科疾病种类统计表 -->
  <div>
    <h1>分科疾病种类统计表</h1>
    <h3>时期: {{startDate}} ~ {{endDate}}</h3>
    <h2>
      <span>医院名称：湖北中医学院附属医院</span>
      <span>科别：{{ officeName }}</span>
      <span>本科例数: {{total}}</span>
    </h2>
    <el-table :data="tableData" stripe border style="width: 100%">
      <el-table-column prop="xh" label="序号" align="center" width></el-table-column>
      <el-table-column prop="icd" label="ICD" align="center" width></el-table-column>
      <el-table-column prop="bm" label="病名" align="center" width="700"></el-table-column>
      <el-table-column prop="f1" label="例数" align="center" width></el-table-column>
      <el-table-column prop="f2" label="占本科例数%" align="center" width></el-table-column>
    </el-table>
  </div>
</template>

<script>
import { selectBranchDiseaseSpecies } from "@/api";
import { showOkMsg, showErrorMsg } from "@/utils/index.js";

export default {
  data() {
    return {
      tableData: [],
      startDate: "",
      endDate: "",
      officeName: "",
      total: 0
    };
  },
  created() {
    this.getTableList();
  },
  props: ["dateList"],
  methods: {
    getTableList() {
      if (this.dateList.dateBegin && this.dateList.dateEnd) {
        selectBranchDiseaseSpecies({
          categoryCode: this.dateList.administrative,
          serialNumber: this.dateList.num,
          startDate: this.dateList.dateBegin,
          endDate: this.dateList.dateEnd
        }).then(res => {
          if (res.code === 0) {
            this.startDate = this.dateList.dateBegin;
            this.endDate = this.dateList.dateEnd;
            this.officeName = this.dateList.officeLable;
            this.tableData = res.data;
            this.total = 0;
            this.tableData.forEach(ele => {
              this.total += ele.f1;
            });
            showOkMsg(res.msg);
          }
        });
      } else {
        showErrorMsg("请选择开始或结束日期");
      }
    }
  }
};
</script>

<style scoped>
h1 {
  font-size: 24px;
  text-align: center;
  padding: 23px 0;
}
h3 {
  text-align: center;
  padding-bottom: 20px;
}
h2 {
  padding: 4px 0;
  display: flex;
  justify-content: space-between;
}
</style>